home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
nan_news
/
vol2
/
no4
/
enc.c
< prev
next >
Wrap
Text File
|
1988-05-18
|
1KB
|
60 lines
#include "c:\s87\misc\nandef.h"
#include "c:\s87\misc\extend.h"
/*
Function: ENCRYPT()
Syntax: ENCRYPT( <expC1>, <expC2>, BUFFER )
Purpose: To encrypt <expC1> using <expC2> as the key and
storing the result in BUFFER.
Author: Bao Hoang
Date: 03/02/88
Time: 01:32:46
Documented: Not really.
*/
CLIPPER encrypt()
{
char *string, /* string to encrypt */
*key, /* key to use for encryption */
*res, /* string to put result in */
*tmp, /* temporary key pointer */
*res_ptr; /* result temporary pointer */
int s_len, /* length of string to encrypt */
k_len, /* length of key */
tk_len; /* temporray key length counter */
/*
Step 1: Get the parameters!
C me interface? (chuckle, chuckle...)
*/
string = _parc(1);
s_len = _parclen(1);
key = _parc(2);
k_len = _parclen(2);
res = _parc(3);
/*
Step 2: Go encrypt the thang!
*/
res_ptr = res;
tk_len = k_len;
for (tmp = key; s_len-- > 0; *res_ptr++ = *string++ ^ *tmp++)
if (tk_len-- == 0)
{
tmp = key;
tk_len = k_len;
}
/*
Step 3: Let's go home!
*/
_ret();
}